#coding: utf-8
class CulturalHeritage::Part < ActiveRecord::Base
  default_scope where("deleted = 0")
  belongs_to :obj_cultural_heritage, :class_name => 'CulturalHeritage::CulturalHeritage',  :foreign_key => 'cultural_heritage'

  def self.count_cultural_heritage_dependencies(id)
      return find(:all,:conditions=>["cultural_heritage_parts.cultural_heritage = ? and (cultural_heritage_parts.deleted = ?) ",id,0],:select=>"count(*) as 'parts'")[0].parts.to_i
  end
end
